TimeLeft()

Preemption Logic System Function

Syntax samples

TIMELEFT()

Attr1=TIMELEFT()

Description

Returns the time remaining if the preemption occurred during a WAIT statement. The value returned is in default time units and must be checked before any processing delay occurs since the value is updated whenever a preemption takes place. If the value is referred to later, it should be assigned to the entity’s attribute or to a local variable.

If several entities were preempted at a location, the value returned by the function to each entity will be taken from whichever entity has the largest time remaining in the WAIT statement.

When no units are specified in the parentheses in this function, it returns the default time unit specified in the General Information dialog.

Valid In

Operation logic defined as a preemptive process.

Example

You may preempt an entity called Gear while it processes at a location called Lathe1. When you preempt the Gear, it should go to a location called Wait_Area where it waits to return to Lathe1. When it returns to Lathe1, the lathe should continue processing the Gear from where it left off when you preempted the Gear. For example, if Lathe1 must process the Gear for a total of 10 minutes, but it only processes for 8 minutes before you preempt the Gear, Lathe1 should process it for only 2 additional minutes when it returns to Lathe1. To do this, we assign the remaining process time using TIMELEFT() to an attribute, Att1. We also check Att1 at Lathe1 to determine if it is greater than 0 to know whether the Gear was executing the process for the first time or as a preempted entity. Processing should be as follows:

Process Table

Entity

Location

Operation (min)

Gear

Lathe1

IF Att1=0 THEN WAIT 10

ELSE WAIT Att1

Gear *

Lathe1

Att1=TIMELEFT()

Gear

Wait_Area

 

* Preemptive Process Record

Routing Table

Blk

Output

Destination

Rule

Move Logic

1

Gear

Lathe2

FIRST 1

 

1

Gear

Wait_Area

FIRST 1

 

1

Gear

Lathe1, 99

FIRST 1

 

See Also

Preemption Process Logic.